#ifndef GLOBAL_H_INCLUDED
#define GLOBAL_H_INCLUDED

// Global configuration
#define TZM_PERFORMANCE
#ifndef TZM_PERFORMANCE
	#define TZM_PRECISION
#endif
#define TZM_FORBID_RENDERTARGETS

#define TZM_BUILD_SAFEMODE
#define TZM_BUILD_DEBUGMODE

// Type definitions
#include <iostream>
#include <string.h>
#include <fstream>
#include <cstdarg>
#include <list>
#include <map>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;


typedef string str;
typedef unsigned int 	uint;
typedef unsigned int 	uint32;
typedef unsigned int 	ui32;
typedef unsigned short 	ushort;
typedef unsigned short 	uint16;
typedef unsigned short 	ui16;
typedef unsigned char 	byte;
typedef unsigned long 	ulong;
typedef unsigned long 	uint64;
typedef unsigned long 	ui64;
typedef void*	data;
typedef void*	handle;

#ifdef PIE_PERFORMANCE
	typedef float real;
#else
	typedef double real;
#endif

typedef const uint 	cuint;
typedef const uint32 cuint32;
typedef const ui32 	cui32;
typedef const ushort cushort;
typedef const uint16 cuint16;
typedef const ui16 	cui16;
typedef const byte 	cbyte;
typedef const ulong 	culong;
typedef const uint64 cuint64;
typedef const ui64 	cui64;
typedef const real 	creal;
typedef const int 	cint;

// Global definitions:
#define FREE(a)	if(a) { delete a;		a = NULL; }
#define FREEA(a)	if(a) { delete [] a; a = NULL; }

#ifdef PIE_PERFORMANCE
	#define EPS		0.00000001f
	#define PI		3.14159265f
	#define HALFPI 1.57079633f
	#define d2r(a)	0.01745329f*a
	#define r2d(a) 57.2957795f*a
	#define HALF	0.5f
	#define THIRD  0.33333333f
#else
	#define EPS		0.00000001
	#define PI		3.14159265
	#define HALFPI 1.57079633
	#define d2r(a)	0.01745329*a
	#define r2d(a) 57.2957795*a
	#define HALF	0.5
	#define THIRD  0.33333333
#endif

#define KBYTE 1048576
#define MBYTE 1073741824
#define UNDER1(a) (real)1/(real)a
#define JUST_DONT 0

/// Maps unsigned 8 bits/channel to TZM Color
#define tzmRGBA(r,g,b,a)	((ulong)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
#define tzmRGB(r,g,b)		tzmRGBA(r,g,b,0xff)

/// Flags used to define the behaviour of a databuffer resource
enum eDATABUFFER_FLAGS {
	eDBF_DEFAULT_SETTINGS 	= 0,
	eDBF_VRAM 					= 1,
	eDBF_RAM  					= 2,
	eDBF_STATIC 				= 4,
	eDBF_DYNAMIC 				= 8,
	eDBF_PERSISTENT 			= 16,
	eDBF_RENDERTARGET			= 32
};

#endif // GLOBAL_H_INCLUDED
